import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
// import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '名称',
    align: "center",
    dataIndex: 'name'
  },
  {
    title: '是否启用',
    align: "center",
    dataIndex: 'status',
    filters: [
      { text: '是', value: '1' },
      { text: '否', value: '0' },
    ],
    filterMultiple: false,
    // customRender:({text}) => {
    //    return  render.renderSwitch(text, [{text:'是',value:'1'},{text:'否',value:'0'}]);
    //  },
    slots: { customRender: 'isOpenSlot' },
  },
  {
    title: '是否固定',
    align: "center",
    dataIndex: 'fixed',
    filters: [
      { text: '是', value: '1' },
      { text: '否', value: '0' },
    ],
    filterMultiple: false,
    slots: { customRender: 'isFixedSlot' },
  },
  // {
  //   title: '创建人',
  //   align: "center",
  //   dataIndex: 'createBy'
  // },
  {
    title: '创建日期',
    align: "center",
    sorter: true,
    dataIndex: 'createTime'
  },
  {
    title: '更新日期',
    align: "center",
    sorter: true,
    dataIndex: 'updateTime'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "创建日期",
    field: "createTime",
    component: 'RangePicker',
    componentProps: {
      showTime: true,
    },
    colProps: {span: 6},
  },
  {
    label: "名称",
    field: 'name',
    component: 'Input',
    colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入名称!'},
              {...rules.duplicateCheckRule('caishui_signing_service', 'name',model,schema)[0]},
             ];
    },
  },
  {
    label: '是否启用',
    field: 'status',
    component: 'JSwitch',
    componentProps:{
      options: ['1', '0'],
    },
    dynamicRules: () => {
      return [
              { required: true, message: '请输入是否启用!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
